package medium;

import java.util.Arrays;

/**
 * 1702. 修改后的最大二进制字符串
 * 创建时间：2024-04-11 09:32
 */
public class 修改后的最大二进制字符串_1702 {
    static class Solution {
        public String maximumBinaryString(String binary) {
            int i = binary.indexOf("0");
            if (i < 0) {
                return binary;
            }
            char[] s = binary.toCharArray();
            int cnt = 0;
            for (i++; i < s.length; i++) {
                cnt += s[i] - '0';
            }
            char[] rsl = new char[s.length];
            Arrays.fill(rsl, '1');
            rsl[s.length - cnt] = '0';
            return Arrays.toString(rsl);
            //return 1".repeat(s.length - 1 - cnt) + "0" + "1".repeat(cnt);
        }

        public static void main(String[] args) {
            Solution s = new Solution();
            System.out.println(s.maximumBinaryString("1010101"));
        }
    }
}
